{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f7bc498c",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fca4df49",
   "metadata": {},
   "source": [
    "## 1读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "9b920397",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = np.loadtxt(\"ShanghaiPM20100101_20151231.csv\", delimiter=\",\",  skiprows=1,  dtype=str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "680af568",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([['1', '2010', '1', ..., '1', '0', '0'],\n",
       "       ['2', '2010', '1', ..., '2', '0', '0'],\n",
       "       ['3', '2010', '1', ..., '4', '0', '0'],\n",
       "       ...,\n",
       "       ['52582', '2015', '12', ..., '22', '0', '0'],\n",
       "       ['52583', '2015', '12', ..., '25', '0', '0'],\n",
       "       ['52584', '2015', '12', ..., '27', '0', '0']], dtype='<U6')"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "ccbbc1d9",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[['1' '2010' '1' ... '1' '0' '0']\n",
      " ['2' '2010' '1' ... '2' '0' '0']\n",
      " ['3' '2010' '1' ... '4' '0' '0']\n",
      " ...\n",
      " ['52582' '2015' '12' ... '22' '0' '0']\n",
      " ['52583' '2015' '12' ... '25' '0' '0']\n",
      " ['52584' '2015' '12' ... '27' '0' '0']]\n"
     ]
    }
   ],
   "source": [
    "print(data)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "045bf3f7",
   "metadata": {},
   "source": [
    "## 2切片，只截取需要的数据范围"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "c7b238f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['17445', '2011', '12', '28', '20', '4', 'NA', '44', 'NA', '5',\n",
       "       '71.07', '1028.1', '10', 'NE', '11', '0', '0'], dtype='<U6')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[17443:][1,]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "88f532e6",
   "metadata": {},
   "source": [
    "## 3读取北京数据，准备和上海数据合并"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "9f9af92f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([['1', '2010', '1', ..., '1.79', '0', '0'],\n",
       "       ['2', '2010', '1', ..., '4.92', '0', '0'],\n",
       "       ['3', '2010', '1', ..., '6.71', '0', '0'],\n",
       "       ...,\n",
       "       ['52582', '2015', '12', ..., '0.89', '0', '0'],\n",
       "       ['52583', '2015', '12', ..., '1.78', '0', '0'],\n",
       "       ['52584', '2015', '12', ..., '2.67', '0', '0']], dtype='<U11')"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataBeijing = np.loadtxt(\"BeijingPM20100101_20151231_shan.csv\", delimiter=\",\",  skiprows=1,  dtype=str)\n",
    "dataBeijing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2ed43874",
   "metadata": {},
   "outputs": [],
   "source": [
    "dataBeijing.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "d63b98e7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([['1', '2010', '1', ..., '1', '0', '0'],\n",
       "       ['2', '2010', '1', ..., '2', '0', '0'],\n",
       "       ['3', '2010', '1', ..., '4', '0', '0'],\n",
       "       ...,\n",
       "       ['52582', '2015', '12', ..., '0.89', '0', '0'],\n",
       "       ['52583', '2015', '12', ..., '1.78', '0', '0'],\n",
       "       ['52584', '2015', '12', ..., '2.67', '0', '0']], dtype='<U11')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataStack=np.vstack((data,dataBeijing))\n",
    "dataStack"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "696cb7dd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(105168, 17)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dataStack.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "f9d7d034",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "print(\"1\")\n",
    "\n",
    "print(\"2\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
